// pages/yuyue-list/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userimg:"",
    pname:"",
    applytime:"",
    aId:"",
    status:"",
    appoint:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var userimg = app.globalData.userInfo.Avatar
    this.setData({
      userimg: userimg
    })
    this.orderList()
  },
  //获取预约列表
  orderList:function(){
    var that = this;
    wx.showLoading({
      title: '加载中...',
    })
    wx.request({
      url: app.globalData.host + '/api/user/AppointList?uid=' + app.globalData.userInfo.Uid,
      success: function (res) {
        console.log("预约列表")
        console.log(res);
       if(res.data.Code == 0){
         that.setData({
           appoint: res.data.Data
         })
       }
      }
    })
    setTimeout(function () {
      wx.hideLoading()
    }, 200)
  },

  //取消预约offOrder
  offOrder:function(e){
    var that = this;
    var aid = e.currentTarget.dataset.aid
    wx.request({
      url: app.globalData.host + '/api/user/AppointCancel?aid=' + aid,
      success: function (res) {
        wx.showToast({
          title: '取消成功',
          icon: 'success',
          duration: 2000
        })
        wx.redirectTo({
          url: "/pages/yuyue-list/index",
        });
      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  }
})